package com.qsmx.store.app.main;

import android.os.Build;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.qsmx.store.app.R;
import com.qsmx.store.app.databinding.DelegateMachineInfoBinding;
import com.qsmx.store.app.util.ApkManager;
import com.qsmx.store.app.util.NetworkUtils;
import com.qsmx.store.core.delegates.AtmosDelegate;
import com.qsmx.store.core.util.dimen.DimenUtil;

import java.util.Objects;

public class MachineInfoDelegate extends AtmosDelegate {

    private DelegateMachineInfoBinding mBinding;

    @Override
    public Object setLayout() {
        return R.layout.delegate_machine_info;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {

        mBinding = DelegateMachineInfoBinding.bind(rootView);

        mBinding.tvWifiIp.setText(String.format(getString(R.string.wifi_ip), NetworkUtils.getWifiIP(requireContext())));
        mBinding.tvWifiMac.setText(String.format(getString(R.string.wifi_mac), NetworkUtils.getWifiMACAddress(requireContext())));
        mBinding.tvNetIp.setText(String.format(getString(R.string.net_ip), NetworkUtils.getEtherNetIP()));
        mBinding.tvNetMac.setText(String.format(getString(R.string.net_mac), NetworkUtils.getEtherNetMAC()));

        mBinding.tvMachineName.setText(String.format(getString(R.string.machine_name), Build.DEVICE));
        mBinding.tvMachineModel.setText(String.format(getString(R.string.machine_model), Build.MODEL));
        mBinding.tvMachineBrand.setText(String.format(getString(R.string.machine_brand), Build.BRAND));
        mBinding.tvMachineManufacturer.setText(String.format(getString(R.string.machine_manufacturer), Build.MANUFACTURER));
        mBinding.tvMachineDpi.setText(String.format(getString(R.string.machine_dpi), DimenUtil.getScreenHeight() + "*" + DimenUtil.getScreenWidth()));
        mBinding.tvAndroidVersion.setText(String.format(getString(R.string.android_version), Build.VERSION.RELEASE));
        mBinding.ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getSupportDelegate().pop();
            }
        });
    }
}
